/**
 * @team Samurai Pizza Cats
 * 1. Tom Doron
 * 2. Gal Rotem
 * 3. Dor Porat
 */
 
import java.util.LinkedList;
import java.util.List;

import lex.Lexer;
import lex.Token;

public class Main
{
	public static void main(String[] args)
	{
		String error = null;
		List<Token> tokens = new LinkedList<Token>();
		try{
			  Lexer lex = new Lexer();
			  System.out.println(String.format("%s\t%s\t%s :\t%s", "token", "tag", "line", "column"));
			  lex.process(args[0], tokens);
	    }
		catch (Exception e)
		{
			error = e.getMessage();
		}
		catch (Error e) {
			error = e.getMessage();
		}
		PrintTokens(tokens, error);
	}
	
	private static void PrintTokens(List<Token> tokens, String errorMessage){
		for (Token t:tokens) {
			System.out.println(String.format("%s\t%s\t%s\t%s", t.text, t.tag, t.line, t.column));
		  }
		if (errorMessage != null){
			System.out.println(errorMessage);
		}
	}
}
